﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
    ZFine.Domain.Entity.CourseEntity thisobj = ViewData["objs"] as ZFine.Domain.Entity.CourseEntity;
   
}
<script>
    var keyValue = $.request("keyValue");

    $(function () {
        var $distpicker = $('#distpicker');
   
        if (!!keyValue) {
            $.ajax({
                url: "/Project/Course/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $distpicker.distpicker({
                        province: data.Province,
                        city: data.City,
                        district: data.Region
                    });
                    $("#form1").formSerialize(data);
                    $("#form1").find('.form-control,select').attr('disabled', 'disabled');

                }
            });
        } else {
            $("#form1").formSerialize("add");
            $distpicker.distpicker({
                province: '内蒙古省',
                city: '呼和浩特市',
                district: '玉泉区'
            });
        }
    });
    function submitForm() {
        var postData = $("#form1").formSerialize();
        if (!$('#form1').formValid()) {
            return false;
        }
        debugger;
        $.submitForm({
            url: "/Project/Course/SubmitForm?keyValue=" + keyValue,
            param: postData,
            success: function() {
                // $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        });
    }
    function saveIntoDrafts() {
        var postData = $("#form1").formSerialize();
        if (!$('#form1').formValid()) {
            return false;
        }
        debugger;
        $.submitForm({
            url: "/Project/Course/SaveIntoDrafts?keyValue=" + keyValue,
            param: postData,
            success: function () {
                // $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        });
    }
</script>
<form id="form1">
    <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#">基本信息</a></li>
        </ul>
        <div style="padding-top: 20px; margin-right: 30px;">
            <table class="form">
                <tr>
                    <th class="formTitle">课程名称</th>
                    <td class="formValue">
                        @{
                            if (thisobj != null)
                            {
                                @thisobj.Name
                            }
                            else
                            {
                                <input id="Name" name="Name" type="text" class="form-control required" placeholder="请输入课程类型"/>
                            }
                        }
                        
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">原价</th>
                    <td class="formValue">
                        <input id="CourseOldPrice" name="CourseOldPrice" class="form-control required" placeholder="请输入课程原价" />
                    </td>
                    <th class="formTitle">现价</th>
                    <td class="formValue">
                        <input id="CourseNowPrice" name="CourseNowPrice"  class="form-control required" placeholder="请输入课程原价" />
                    </td>
                    <th class="formTitle">课程类型</th>
                    <td class="formValue">
                        <input id="CourseType" name="CourseType" type="text"  class="form-control required" placeholder="请输入课程原价" />
                    </td>
                </tr>
                @*<tr>
                    <th class="formTitle">添加人</th>
                    <td class="formValue">
                        <input id="AddUserName" name="AddUserName" type="text" class="form-control " placeholder="未填写时默认当前用户为添加人" />
                    </td>
                </tr>*@
                <tr>
                    <th class="formTitle">课程开始时间</th>
                    <td class="formValue">
                        <input id="CourseStartTime" name="CourseStartTime" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" style="margin-left: 2px" placeholder="请输入发送时间" />
                    </td>
                    <th class="formTitle">课程结束时间</th>
                    <td class="formValue">
                        <input id="CourseEndTime" name="CourseEndTime" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" style="margin-left: 2px" placeholder="请输入发送时间" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">上课时间</th>
                    <td class="formValue">
                        <input id="CourseTime" name="CourseTime" type="text" class="form-control " placeholder="未填写时默认当前用户为添加人" />
                    </td>
                    <th class="formTitle">联系电话</th>
                    <td class="formValue">
                        <input id="PhoneNumber" name="PhoneNumber" type="text" class="form-control required " placeholder="未填写时默认当前用户为添加人" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">所属地区</th>
                    <td class="formValue">
                        <div id="distpicker" class="distpicker" style="width:1044px">
                            <select id="Province" name="province" class="form-control required" style="width: 250px; float: left; display: block;"></select>
                            <select id="City" name="city" class="form-control required" style="width: 250px; float: left;display: block; margin-left: 142px;"></select>
                            <select id="Area" name="Area" class="form-control required" style="width: 250px; float: left; display: block;; margin-left: 142px;"></select>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">详细地址</th>
                    <td class="formValue">
                        <input id="Address" name="Address" type="text" class="form-control required" placeholder="请输入详细地址" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">上传图片</th>
                    <td class="formValue">
                        <input id="Image" name="Image" type="text" class="form-control required" placeholder="最多不超过5张" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">上传视频</th>
                    <td class="formValue">
                        <input id="Video" name="Video" type="text" class="form-control required" placeholder="一经上传不可修改" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">课程介绍</th>
                    <td class="formValue">
                        <input id="Description" name="Description" type="text" class="form-control " placeholder="不超过500字" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">注意事项</th>
                    <td class="formValue">
                        <input id="CourseAlert" name="CourseAlert" type="text" class="form-control " placeholder="" />
                    </td>
                </tr>
                @*<tr>
                    <th class="formTitle" colspan="1">课程说明</th>
                    <td class="formValue" colspan="3">
                        <textarea id="ContenAbstract" name="ContenAbstract" class="form-control" style="height: 60px;"></textarea>
                    </td>
                </tr>*@
            </table>
        </div>
        <div class="form-button" id="wizard-actions">
            <a id="btn_last" class="btn btn-default ">预览</a>
            <a id="btn_next" class="btn btn-default" onclick="saveIntoDrafts">保存至草稿箱</a>
            <a id="btn_finish" class="btn btn-default" onclick="submitForm()">提交审核</a>
        </div>
    </div>
</form>
